URL = "http://svn.tevs.eu/osgPPU/trunk"

# currently version indicates the osg version
VERSIONS = ["3.1.3", "3.2.0", "3.2.1"]
DEFAULT_VERSION = "3.2.1"
DEPENDS = ['osg', 'swig']

from source.builders import CMakeBuilder, FetchSourceSVN
import os

class FetchSourceOsgPPU(FetchSourceSVN):

  def fetch(self, url, downloadlocation, buildlocation ):
    targetdir = "osgPPU-%s" % DEFAULT_VERSION #todo allow custom version
    targetpath = buildlocation + os.sep  + targetdir
    if os.path.exists( targetpath ):
      os.system( self.executable + " update " + targetpath )
    else:
      os.system( self.executable + " checkout " + url + " " + targetpath )
    return targetpath

class OsgSwigBuilder( CMakeBuilder ):
  """ subclass of CMakeBuilder with custom configure step """

  def targetpath(self):
    return self.directories.enviro + os.sep + "osgPPU-%s" % self.dependencies['osg'].target.build_version
    #todo allow FetchSource to be specified like URL, or determine implicit from url

  def downloadextract(self):
    return FetchSourceOsgPPU()

  def configure( self ):
    os.chdir( self.extractedpath )
    OSG_DIR = self.dependencies['osg'].targetpath()
    os.environ['OSGDIR'] = OSG_DIR
    CMakeBuilder.configure(self)

  #def make_devenv(self):
  #  os.chdir( self.extractedpath )
  #  self.debug = False
  #  self.call_devenv( "osgswig.sln", "ALL_BUILD.vcproj" )


BUILDER = OsgSwigBuilder
